#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ----------------------------------------------------------
# -- 钉钉工具
# --
# ****************************
# Author: lmay.Zhou
# Blog: www.lmaye.com
# Date: 2021/9/22 14:39
# Email lmay@lmaye.com
# ----------------------------------------------------------
from dingtalkchatbot import chatbot


def send_msg(spider, error_msg):
    """
        钉钉消息

        :param spider: 爬虫脚本
        :param error_msg: 错误消息
        :return:
    """
    webhook = 'https://oapi.dingtalk.com/robot/send?access_token=xxx'
    secret = 'xxx'
    robot = chatbot.DingtalkChatbot(webhook, secret=secret)
    robot.send_text("[{}] 数据爬取失败: {}".format(spider, error_msg))
